package chap09;

import com.sun.corba.se.spi.activation.Server;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class MultiSeverThread_TCP  extends Thread{
    private Socket client;
    public MultiSeverThread_TCP(Socket clinet){
        this.client= client;
    }
    public void run(){
            try{
                BufferedReader buf=new BufferedReader(new InputStreamReader(client.getInputStream()));
                PrintStream pout=new PrintStream(client.getOutputStream());//out
                boolean temp=true;
                while(temp){
                    String str=null;
                    if(str==null|| "".equals(str)){
                        temp=false;
                        break;
                    }
                    if("bye".equalsIgnoreCase(str)){
                        temp=false;
                        break;
                    }
                }
                buf.close();
                pout.close();
                client.close();
            }catch(IOException e){

            }
    }
    public static void main(String [] args) throws IOException{
        ServerSocket socket=new ServerSocket(8888);
        boolean flag=true;
        while(flag){
            System.out.println("等待客户端连接");
            new Thread(new MultiSeverThread_TCP(socket.accept()));//
        }

    }
}

